from sqlalchemy import create_engine
import pyperclip as clip
import json
import pandas as pd

# 连接database
engine = create_engine('mysql+pymysql://jsbi:jsbi-1701@47.114.55.19:9011/biv1?charset=utf8')
con = engine.connect()

df = pd.read_csv("D:/简尚家居/正在销售的类目.txt")
# df['cat3'] = df['inSalesCat']

# pandas 按照字符串分割后的分列
df[['cat1', 'cat2', 'cat3']] = df['inSalesCat'].str.split('>', 2, expand=True)

# 解决可能出现的超时问题bugfix 2020.08.18
con.connection.connection.ping(reconnect=True)
df.to_sql(name='平台_目前正在用的拼多多类目', con=engine, if_exists='append', index=False)
debug = ''
# df = pd.DataFrame(jsonHtml)
